package com.csc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csc.dao.UserDao;
import com.csc.dao.UserDaoImpl;
import com.csc.domain.User;

@Service
public class UseServiceImpl implements UserService{
	/*@Author Thanh Binh*/
	@Autowired
	UserDao USER_DAO;

	public User checkLogin(String userName, String password) {
		UserDaoImpl userRoleDaoImpl= new UserDaoImpl();
		List<User> users = userRoleDaoImpl.getAllUsers();
		User user = null;		
		for (User userRole : users) {
			if (userRole.getUserName().equals(userName)
					&& userRole.getPassword().equals(password)) {
				user = userRole;
				break;
			}
		}
		return user;
	}

}
